import axios from 'axios'

const state = {
    goodsTypeList: []
}
const mutations = {
    changeGoodsTypeList(state, goodsTypeList) {
        state.goodsTypeList = goodsTypeList
    }

}
const actions = {
    addGoodsTypeList({ dispatch }, params) {
        return axios.post('/goodsTypeList', params)
    },
    getGoodsTypeList({ commit }, params) {
        axios.get('/goodsTypeList', {
            params
        }).then(data => {
            commit('changeGoodsTypeList', data.goodsTypeList)
        })
    },
    deleteGoodsTypeList({dispatch},id){
        axios.delete('/goodsTypeList/'+id,{
            params:{
                id
            }
        }).then(data=>{
            if(data.ok===1){
                dispatch('getGoodsTypeList')
            }
        })
    }
}
export default {
    state,
    mutations,
    actions
}